package com.jinyang.jetpackdemo

import android.content.Context
import androidx.startup.Initializer
import com.jinyang.jetpackdemo.hilt.MyEntryPoint
import com.jinyang.jetpackdemo.util.LjyLogUtil
import com.jinyang.jetpackdemo.util.LjyToastUtil
import dagger.hilt.android.EntryPointAccessors

/**
 * @Author:         LiuJinYang
 * @CreateDate:     2021/8/16
 * @Description:
 */
class LjyInitializer : Initializer<Unit> {
    override fun create(context: Context) {
        LjyToastUtil.getInstance().init(context)
        AppHelper.init(context)
        //调用EntryPointAccessors.fromApplication()函数来获得自定义入口点的实例
        val entryPoint= EntryPointAccessors.fromApplication(context, MyEntryPoint::class.java)
        //再调用入口点中定义的getRetrofit()函数就能得到Retrofit的实例
        val retrofit=entryPoint.getRetrofit()
        LjyLogUtil.d("retrofit:$retrofit")
    }

    override fun dependencies(): List<Class<out Initializer<*>>> {
        return emptyList()
    }
}